package com.linked.order.order.service.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.linked.order.order.bean.po.GoodsDetailPO;
import com.linked.order.order.mapper.IGoodsDetailMapper;
import com.linked.order.order.service.IGoodsDetailService;
import org.springframework.stereotype.Service;

/**
 * @author :dbq
 * @date : 2023/6/9 9:58
 * @description : desc
 */
@Service
public class GoodsDetailServiceImpl implements IGoodsDetailService {

    private final ObjectMapper mapper;

    private final IGoodsDetailMapper goodsDetailMapper;

    public GoodsDetailServiceImpl(ObjectMapper mapper, IGoodsDetailMapper goodsDetailMapper) {
        this.mapper = mapper;
        this.goodsDetailMapper = goodsDetailMapper;
    }

    @Override
    public boolean saveGoodsDetail(GoodsDetailPO param) {
        GoodsDetailPO res = goodsDetailMapper.selectById(param.getGoodsVersionId());
        if (res != null) {
            return true;
        }
        return goodsDetailMapper.insert(param) > 0;
    }
}
